﻿using System;
using GmailAuto.core;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;

namespace GmailAuto.Helpers
{
    public class Navigator : BasePage
    {
        // Locators
        [FindsBy(How = How.CssSelector, Using = ".T-I.J-J5-Ji.T-I-KE.L3")]
        private IWebElement WriteAnEmailButton;

        [FindsBy(How = How.CssSelector, Using = ".J-Ke.n0")]
        private IWebElement InboxLink;

        [FindsBy(How = How.CssSelector, Using = "SentLocator")] 
        private IWebElement SentLink;

        public void GoTo(To to)
        {
            switch (to)
            {
                case To.Incoming:
                    InboxLink.WaitUntilVisible().Click();
                    break;
                case To.Sent:
                    SentLink.WaitUntilVisible().Click();
                    break;
                case To.Mark:
                    throw new NotImplementedException();

            }
        }

        public NewEmailDialog WriteNewEmail()
        {
            WriteAnEmailButton.WaitUntilVisible().Click();
            return new NewEmailDialog();
        }
    }
}
